<?php

/* @var $this yii\web\View */
use yii\helpers\Html;
use app\assets\ChartAsset;
use app\models\MemberActivity;
ChartAsset::register($this);

$this->title = '基金账户';
$this->params['breadcrumbs'][] = $this->title;?>
<div class="page-title">
  <div>
    <h1><i class="fa fa-line-chart"></i> 基金账户</h1>
  </div>
</div>
<div class="card">
  <h3>账户余额 <i class="fa fa-dollar"></i>：<span style='color:red'><?=Html::encode(number_format($this->context->user->nea_count,2))?></span></h3>
  <hr>
  <!--div class="embed-responsive embed-responsive-16by9">
    <canvas class="embed-responsive-item" id="nea_line_chart"></canvas>
  </div-->
</div>

<?php $this->beginBlock('chart_nea-js') ?>
var rawData=
<?php
echo MemberActivity::getMemberCountGoData(Yii::$app->user->getId(),MemberActivity::FETCH_TYPE_COUNT_NEA);
 ?>
 ;

var dates = rawData.map(function (item) {
    return item[0];
});

var datas = rawData.map(function (item) {
    return item[1];
});

var r=185;
var g=38;
var b=154;

	var ctx = $('#nea_line_chart').get(0).getContext("2d");
	var lineChart = new Chart(ctx, {
	type: 'line',
	data: {
		labels: dates,
		datasets: [{
		label: '基金账户变动图',
		backgroundColor: "rgba("+r+", "+g+", "+b+", 0.31)",
		borderColor: "rgba("+r+", "+g+", "+b+", 0.7)",
		pointBorderColor: "rgba("+r+", "+g+", "+b+", 0.7)",
		pointBackgroundColor: "rgba("+r+", "+g+", "+b+", 0.7)",
		pointHoverBackgroundColor: "#fff",
		pointHoverBorderColor: "rgba(220,220,220,1)",
		pointBorderWidth: 1,
		data: datas
		}, ]
	},
	options:{
		elements: {
			line: {
				tension: 0 // no bezier in radar
			}
		}

	}
	});

<?php $this->endBlock() ?>
<?php $this->registerJs($this->blocks['chart_nea-js'],\yii\web\View::POS_END); ?>
